<template>
  <view class="popup-container" v-if="visible">
    <!-- 遮罩层 -->
    <view class="popup-mask" @click="closePopup"></view>

    <!-- 弹窗内容 -->
    <view class="popup-content">
      <view class="options-container">
        <!-- 交换电话 -->
        <view class="option-item" @click="handleOptionClick('交换电话')">
          <uni-icons type="phone" size="40" color="#007AFF"></uni-icons>
          <text class="option-text">交换电话</text>
        </view>

        <!-- 交换微信 -->
        <view class="option-item" @click="handleOptionClick('交换微信')">
          <uni-icons type="weixin" size="40" color="#07C160"></uni-icons>
          <text class="option-text">交换微信</text>
        </view>
      </view>

      <!-- 取消按钮 -->
      <view class="cancel-button" @click="closePopup">取消</view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    // 处理选项点击
    handleOptionClick(action) {
      this.$emit('select', action); // 触发选择事件
      this.closePopup();
    },
    // 关闭弹窗
    closePopup() {
      this.$emit('update:visible', false); // 更新 visible 状态
    }
  }
};
</script>

<style scoped>
.popup-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  flex-direction: column;
  z-index: 999;
}

.popup-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1; /* 遮罩层层级，低于弹窗内容 */
}

.popup-content {
  width: 100%;
  background-color: #fff;
  border-radius: 20rpx 20rpx 0 0;
  padding: 20rpx;
  box-sizing: border-box;
   z-index: 2; /* 弹窗内容层级，高于遮罩层 */
    position: relative; /* 确保层级生效 */
}

.options-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 20rpx 0;
}

.option-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40%;
  padding: 20rpx;
  border-radius: 10rpx;
  background-color: #fff;
}

.option-item:active {
  background-color: #e5e5e5; /* 点击效果 */
}

.option-text {
  font-size: 28rpx;
  color: #333;
  margin-top: 10rpx;
}

.cancel-button {
  padding: 30rpx;
  font-size: 32rpx;
  text-align: center;
  color: #999;
  margin-top: 20rpx;
  border-top: 1rpx solid #e5e5e5;
}
</style>